package com.database.bean;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name="REPORT_DECISION")
@AttributeOverride( name="id", column = @Column(name="id") )
@XmlRootElement
public class ReportDecision extends BaseBean{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@ManyToOne
	@JoinColumn(name="report_id")
	private Report report=null;   
	
	@ManyToOne
    @JoinColumn(name="decres_Id")
	private CompanyRoundDecisionAndResult decRes=null;
	
	@Column(name="targetCompany_Id")
	private Integer targetCompany_Id=null;
	
	public ReportDecision(){}
	
	/**
	 * 
	 * @param decres
	 * @return
	 */
	public ReportDecision getCopy(CompanyRoundDecisionAndResult decres){
		ReportDecision repdec = new ReportDecision();
		Report newReport = this.report;
		//newReport.setReportDecisions(null);
		//clone
		
		repdec.setReport(newReport);
		repdec.setTargetCompany_Id(this.targetCompany_Id);
		repdec.setDecRes(decres);
		return repdec;
	}
	
	/**
	 * 
	 * @return
	 */
	public Integer getRoundNumber(){
		if(this.getDecRes()!=null && this.getDecRes().getRound()!=null){
			return this.getDecRes().getRound().getRoundNumber();
		}else{
			return null;
		}
	}

	/**
	 * @return the report
	 */
	public Report getReport() {
		return report;
	}

	/**
	 * @param report the report to set
	 */
	public void setReport(Report report) {
		this.report = report;
	}

	/**
	 * @return the decRes
	 */
	public CompanyRoundDecisionAndResult getDecRes() {
		return decRes;
	}

	/**
	 * @param decRes the decRes to set
	 */
	public void setDecRes(CompanyRoundDecisionAndResult decRes) {
		this.decRes = decRes;
	}

	/**
	 * @return the targetCompany_Id
	 */
	public Integer getTargetCompany_Id() {
		return targetCompany_Id;
	}

	/**
	 * @param targetCompany_Id the targetCompany_Id to set
	 */
	public void setTargetCompany_Id(Integer targetCompany_Id) {
		this.targetCompany_Id = targetCompany_Id;
	}


	@Override
	public String toString() {
		return "ReportDecision [report=" + report + ", decRes=" + decRes
				+ ", targetCompany_Id=" + targetCompany_Id + "]";
	}

}
